/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package cn.pp.pwdkeyboard;

import android.content.Context;
import android.content.res.AssetManager;
import android.os.Build;
import cn.pp.custom.a;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;

public class InitKeyboard {
    public static void a(Context paramContext, String paramString) {
        System.load(paramString);
    }

    public int a(String paramString, Context paramContext) {
        File localFile = new File(paramString);
        if (!(localFile.exists())) {
            String str1 = Build.CPU_ABI;
            String str2 = "so/armeabi/pp_encrypt";
            if (str1.indexOf("mips") != -1)
                str2 = "so/mips/pp_encrypt";
            else if (str1.indexOf("x86") != -1)
                str2 = "so/x86/pp_encrypt";
            else if (str1.indexOf("armeabi-v7a") != -1)
                str2 = "so/armeabi-v7a/pp_encrypt";
            FileOutputStream localFileOutputStream = null;
            try {
                localFileOutputStream = paramContext.openFileOutput("libpp_encrypt.so", 0);
            } catch (FileNotFoundException localFileNotFoundException) {
                localFileNotFoundException.printStackTrace();
                return -1;
            }
            InputStream localInputStream = null;
            try {
                localInputStream = paramContext.getAssets().open(str2);
            } catch (IOException localIOException1) {
                localIOException1.printStackTrace();
                return -1;
            }
            byte[] arrayOfByte = (byte[]) null;
            try {
                arrayOfByte = a(localInputStream);
                localFileOutputStream.write(arrayOfByte);
                localFileOutputStream.close();
            } catch (IOException localIOException2) {
                localIOException2.printStackTrace();
                return -1;
            }
        }
        return 0;
    }

    private byte[] a(InputStream paramInputStream) {
        ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream();
        int i;
        while ((i = paramInputStream.read()) != -1)
            localByteArrayOutputStream.write(i);
        byte[] arrayOfByte = localByteArrayOutputStream.toByteArray();
        localByteArrayOutputStream.close();
        return arrayOfByte;
    }

    public String a(byte[] paramArrayOfByte) {
        String str = "";
        a locala = new a();
        locala.byteData = new byte[0];
        int i = getCreditInfoEncrypt(paramArrayOfByte, paramArrayOfByte.length, locala);
        if (i == 0)
            try {
                str = new String(locala.byteData, "utf-8");
            } catch (UnsupportedEncodingException localUnsupportedEncodingException) {
                localUnsupportedEncodingException.printStackTrace();
                return "";
            }
        return str;
    }

    public String b(byte[] paramArrayOfByte) {
        String str = "";
        a locala = new a();
        locala.byteData = new byte[0];
        int i = getEncryptFinall(paramArrayOfByte, paramArrayOfByte.length, locala);
        if (i == 0)
            try {
                str = new String(locala.byteData, "utf-8");
            } catch (UnsupportedEncodingException localUnsupportedEncodingException) {
                localUnsupportedEncodingException.printStackTrace();
                return "";
            }
        return str;
    }

    public byte[] a(byte[] paramArrayOfByte, int paramInt) {
        a locala = new a();
        locala.byteData = new byte[0];
        passwordEncrypt(paramArrayOfByte, paramInt, locala);
        return locala.byteData;
    }

    private native int passwordEncrypt(byte[] paramArrayOfByte, int paramInt, a parama);

    private native int getEncryptFinall(byte[] paramArrayOfByte, int paramInt, a parama);

    private native int getCreditInfoEncrypt(byte[] paramArrayOfByte, int paramInt, a parama);
}